
Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class LineCaps

    Private Sub LineCaps_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim cx As Integer = Me.Width
        Dim cy As Integer = Me.Height

        Dim penWide As Pen = New Pen(Color.Gray, Font.Height)
        Dim penNarrow As Pen = New Pen(Color.Black)
        Dim brush As Brush = New SolidBrush(Color.Black)

        Dim lc As LineCap

        For Each lc In [Enum].GetValues(GetType(LineCap))
            e.Graphics.DrawString(lc.ToString(), Font, brush, Font.Height, Font.Height / 2)

            penWide.StartCap = lc
            penWide.EndCap = lc

            e.Graphics.DrawLine(penWide, 2 * cx \ 4, Font.Height, 3 * cx \ 4, Font.Height)
            e.Graphics.DrawLine(penNarrow, 2 * cx \ 4, Font.Height, 3 * cx \ 4, Font.Height)
            e.Graphics.TranslateTransform(0, 2 * Font.Height)
        Next
    End Sub
End Class